//⽤最少数量的箭引爆⽓球（medium）: https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons/description/
class Solution {
public:
    int findMinArrowShots(vector<vector<int>>& points) {
        // 1. 按照左端点排序
        sort(points.begin(), points.end());
        // 2. 求互相重叠区间的数量
        int right = points[0][1];
        int ret = 1;
        for (int i = 1; i < points.size(); i++) 
        {
            int a = points[i][0], b = points[i][1];
            if (a <= right) // 有重叠部分
            {
                right = min(right, b);
            }
            else // ⽆重叠部分
            {
                ret++;
                right = b;
            }
        }
        return ret;
    }
};